<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-logic" prefix="logic"%>
<html:html>
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>
  <bean:message key="F0404.title"/>
  </title>
  <META http-equiv=Pragma content=no-cache>
  <META http-equiv=Cache-Control content=no-cache>
  <META http-equiv=Expires content=0>
  <link rel="stylesheet"
		href="<%=request.getContextPath()%>/resource/css/style.css"
		type="text/css">
  <script language="javascript" type="text/javascript"
		src="<%=request.getContextPath()%>/resource/js/util.js"></script>
  <script language="javascript" type="text/javascript"
		src="<%=request.getContextPath()%>/style/scripts/util.js"></script>
  <script language="javascript" type="text/javascript"
		src="<%=request.getContextPath()%>/resource/js/AdyhUtil.js"></script>
  <script language="javascript" type="text/javascript"
		src="<%=request.getContextPath()%>/resource/js/Validator.js"></script>
  <script language="javascript" type="text/javascript"
		src="<%=request.getContextPath()%>/resource/calendar/DCDA_C03.js"></script>
  <script>
/**保存*/
function ShowAlert()
{	
	ResetMe();
	var supplierName = Jtrim(document.getElementById("supplierName").value);
	var supplierAddr = Jtrim(document.getElementById("supplierAddr").value);
	var VAT = Jtrim(document.getElementById("VAT").value);
	var contractName = Jtrim(document.getElementById("contractName").value);
	var faxNumber = Jtrim(document.getElementById("faxNumber").value);
	var phoneNumber = Jtrim(document.getElementById("phoneNumber").value);
	var objPrompt = document.getElementById("divPrompt");
    objPrompt.style.display = "block";
    objPrompt.innerHTML = "";
	if(supplierName.length==0||supplierAddr.length==0||VAT.length==0||isNumber(VAT)||parseInt(VAT)<0||
	checkPhone(phoneNumber)==false||phoneNumber.length==0||faxNumber.length!=0||contractName.length==0){
		if(supplierName.length==0){
			objPrompt.innerHTML += "<li><bean:message key="F0404.supplierName"/><bean:message key="adyh.error.isnull"/>！";
			document.getElementById("supplierName").className = "MyControlError";
		}		
		if(supplierAddr.length==0){
			objPrompt.innerHTML += "<li><bean:message key="F0404.supplierAddress"/><bean:message key="adyh.error.isnull"/>！";
			document.getElementById("supplierAddr").className = "MyControlError";
		}
		if(VAT.length==0){
			objPrompt.innerHTML += "<li><bean:message key="adyh.vat"/><bean:message key="adyh.error.isnull"/>！";
			document.getElementById("VAT").className = "MyControlError";
		}else if(isNumber(VAT)||parseInt(VAT)<0){
			objPrompt.innerHTML += "<li><bean:message key="adyh.vat"/><bean:message key="adyh.error"/>！";
			document.getElementById("VAT").className = "MyControlError";
		}		
		if(contractName.length==0){
			objPrompt.innerHTML += "<li><bean:message key="F0404.contractName"/><bean:message key="adyh.error.isnull"/>！";
			document.getElementById("contractName").className = "MyControlError";
		}
		if(phoneNumber.length==0){
			objPrompt.innerHTML += "<li><bean:message key="adyh.telNumber"/><bean:message key="adyh.error.isnull"/>！";
			document.getElementById("phoneNumber").className = "MyControlError";
		}else if(!checkPhone(phoneNumber)){
			objPrompt.innerHTML += "<li><bean:message key="adyh.telNumber"/><bean:message key="adyh.error"/>！";
			document.getElementById("phoneNumber").className = "MyControlError";
		}
		if(faxNumber.length!=0){
			if(!check_fax(faxNumber)){
				objPrompt.innerHTML += "<li><bean:message key="adyh.faxNumber"/><bean:message key="adyh.error"/>！";
				document.getElementById("faxNumber").className = "MyControlError";
			}
		}
		
	}else{
		document.getElementById("supplierName").value = supplierName;
		document.getElementById("supplierAddr").value = supplierAddr;
		document.getElementById("VAT").value = VAT;
		document.getElementById("contractName").value = contractName;
		document.getElementById("faxNumber").value = faxNumber;
		document.getElementById("phoneNumber").value = phoneNumber;
		var operationType = document.getElementById("operationType").value;
		if("add"==operationType){
			operationType = "insert";
		}else if("edit"==operationType){
			operationType = "update";
		}
		operation(operationType);
	}
}

/**重置*/
function ResetMe()
{
    document.getElementById("supplierName").className = "MyText";
	document.getElementById("supplierAddr").className = "MyArea";
	document.getElementById("VAT").className = "MyText";
	document.getElementById("contractName").className = "MyText";
	document.getElementById("faxNumber").className = "MyText";
	document.getElementById("phoneNumber").className = "MyText";
	
	var objPrompt = document.getElementById("divPrompt");
    objPrompt.style.display = "none";
	objPrompt.innerHTML = "";
}
function ShowFormTitle(strTitle)
{
	document.write("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"height:26px; background-position: left bottom; background-image: url(../../resource/image/FormTitle_A_4.gif); background-repeat: repeat-x;\">");
	document.write("  <tr >");
	document.write("	<td style=\"width:5px; background-position: left bottom; background-image: url(../../resource/image/FormTitle_A_1.gif); background-repeat: no-repeat;\">&nbsp;&nbsp;&nbsp;</td>");
	document.write("	<td class=\"FormTitle\" style=\"width:100%; padding-left:5px; padding-top:3px; background-position: left bottom; background-image: url(../../resource/image/FormTitle_A_2.gif); background-repeat: no-repeat;\">");
	document.write("		<span id=\"spanFormTitle\" class=\"SpanTitle\">"+ strTitle +"</span>");
	document.write("	</td>");
	document.write("	<td style=\"width:5px; background-position: right bottom; background-image: url(../../resource/image/FormTitle_A_3.gif); background-repeat: no-repeat;\">&nbsp;&nbsp;&nbsp;</td>");
    document.write("  </tr>");
	document.write("</table>");
}
</script>
  </head>
  <body>
  <html:form method="post" action="/pages/F04/F0404.do">
    <html:hidden property="operationType" />
    <html:hidden property="errorFlag" />
	<html:hidden property="language"/>
    <!--Begin：表单标题-->
    <div class="DivBlock">
      <script language="javascript" type="text/javascript">
		ShowFormTitle("<bean:message key="F0404.title"/>");
	</script>
    </div>
    <!--End：表单标题-->
    <!--Begin：表单主体区块-->
    <div class="DivBlock">
      <div class="DivWrap" style="display:block">
        <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0">
          <TR>
            <TD ALIGN="right" NOWRAP><!--供应商名称-->
              <bean:message key="F0404.supplierName"/>
            </TD>
            <TD colspan="3" ALIGN="left" NOWRAP><html:text property="supplierName" styleClass="MyText" style="width:422" maxlength="50" />
              <span class="Need">*</span></TD>
            <TD ALIGN="right" NOWRAP>&nbsp;</TD>
            <TD ALIGN="left" NOWRAP>&nbsp;</TD>
          </TR>
          <TR>
            <TD ALIGN="right" NOWRAP><!--供应商地址-->
              <bean:message key="F0404.supplierAddress"/>
            </TD>
            <TD ALIGN="left" NOWRAP colspan="3"><html:text property="supplierAddr" styleClass="MyText"  style="width:422" maxlength="100"/>
              <span class="Need">*</span> </TD>
            <TD ALIGN="right" NOWRAP><!--增值税-->
              <bean:message key="adyh.vat"/>
            </TD>
            <TD ALIGN="left" NOWRAP><html:text property="VAT" styleClass="MyText"  style="text-align:right" maxlength="5"/>
              <span class="Need">*</span> </TD>
          </TR>
          <TR>
            <TD ALIGN="right" NOWRAP><!--联系人-->
              <bean:message key="F0404.contractName"/>
            </TD>
            <TD ALIGN="left" NOWRAP><html:text property="contractName" styleClass="MyText" maxlength="20"></html:text>
              <span class="Need">*</span> </TD>
            <TD ALIGN="right" NOWRAP><!--电话号码-->
              <bean:message key="adyh.telNumber"/>
            </TD>
            <TD ALIGN="left" NOWRAP><html:text property="phoneNumber" styleClass="MyText" maxlength="20"></html:text>
              <span class="Need">*</span> </TD>
            <TD ALIGN="right" NOWRAP><!--传真号码-->
              <bean:message key="adyh.faxNumber"/>
            </TD>
            <TD ALIGN="left" NOWRAP><html:text property="faxNumber" styleClass="MyText" maxlength="20"></html:text></TD>
          </TR>
        </TABLE>
      </div>
    </div>
    <!--End：表单主体区块-->
    <!--Begin：表单按钮及提示区-->
    <div class="DivBlock">
      <div class="DivButton">
        <input type="button" name="Submit1" class="MyButton"
					onClick="ShowAlert()" value="<bean:message key="common.save"/>">
        <input type="button" name="Submit2" class="MyButton" value="<bean:message key="common.back"/>"
        onClick="javascript:operation('detailBack');"> </div>
      <div class="DivPrompt" id="divPrompt" style="display:none"> </div>
    </div>
    <!--End：表单按钮及提示区-->
  </html:form>
  </body>
</html:html>
<script language="javascript" type="text/javascript">
InitForm();
</script>
